﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using gnu.trove.list.array;
using ikvm.extensions;
using lineage2.commons.util;

namespace Game.templates.npc
{
    public class Faction
    {
	    /**
	     * Field none. (value is ""none"")
	     */
	    public static String none = "none";
	    /**
	     * Field NONE.
	     */
	    public static Faction NONE = new Faction(none);
	    /**
	     * Field factionId.
	     */
	    public String factionId;
	    /**
	     * Field factionRange.
	     */
	    public int factionRange;
	    /**
	     * Field ignoreId.
	     */
	    public TIntArrayList ignoreId = (TIntArrayList) TroveUtils.EMPTY_INT_ARRAY_LIST;
	
	    /**
	     * Constructor for Faction.
	     * @param factionId String
	     */
	    public Faction(String factionId)
	    {
		    this.factionId = factionId;
	    }
	
	    /**
	     * Method getName.
	     * @return String
	     */
	    public String getName()
	    {
		    return factionId;
	    }
	
	    /**
	     * Method setRange.
	     * @param factionRange int
	     */
	    public void setRange(int factionRange)
	    {
		    this.factionRange = factionRange;
	    }
	
	    /**
	     * Method getRange.
	     * @return int
	     */
	    public int getRange()
	    {
		    return factionRange;
	    }
	
	    /**
	     * Method addIgnoreNpcId.
	     * @param npcId int
	     */
	    public void addIgnoreNpcId(int npcId)
	    {
		    if (ignoreId.isEmpty())
		    {
			    ignoreId = new TIntArrayList();
		    }
		    ignoreId.add(npcId);
	    }
	
	    /**
	     * Method isIgnoreNpcId.
	     * @param npcId int
	     * @return boolean
	     */
	    public bool isIgnoreNpcId(int npcId)
	    {
		    return ignoreId.contains(npcId);
	    }
	
	    /**
	     * Method isNone.
	     * @return boolean
	     */
	    public bool isNone()
	    {
		    return factionId.isEmpty() || factionId.equals(none);
	    }
	
	    /**
	     * Method equals.
	     * @param faction Faction
	     * @return boolean
	     */
	    public bool equals(Faction faction)
	    {
		    if (isNone() || !faction.getName().equalsIgnoreCase(factionId))
		    {
			    return false;
		    }
		    return true;
	    }
	
	    /**
	     * Method equals.
	     * @param o Object
	     * @return boolean
	     */
	    
	    public bool equals(Object o)
	    {
		    if (o == this)
		    {
			    return true;
		    }
		    if (o == null)
		    {
			    return false;
		    }
		    if (o.getClass() != this.getClass())
		    {
			    return false;
		    }
		    return equals((Faction) o);
	    }
	
	    /**
	     * Method toString.
	     * @return String
	     */
	    public String toString()
	    {
		    return isNone() ? none : factionId;
	    }
    }

}
